<#include "../header.html">
<script type="text/javascript">
(function(window){
	var upload={
		initUpload:function(){
			$("#imgFile").change(Upload.checkUpload);
		},
		checkUpload:function(){
			var imgFile = $("#imgFile").val();
			if(imgFile==null || JFT.isBlank(imgFile)){
				alert("请选择上传文件");
				return;
			}
			if(!JFT.checkFile(imgFile, "ipa")){
				alert("上传文件格式必须是[ipa]");
				return;
			}
            $("#appUrlIos", parent.document).val("上传中,请等待");
			$("#uploadBtnIos", parent.document).attr("disabled",true);
			document.uploadForm.submit();
		},
		handleUpload:function(code, imgSrc){
			$("#uploadBtnIos", parent.document).attr("disabled",false);
			if(code == 0) {
                alert("上传成功");
				$("#appUrlIos", parent.document).val(imgSrc);
				return;
			}else if(code == 1){
				alert("上传失败");
				return;
			}else if(code == 3) {
				alert("不支持的扩展名");
				return;
			}
		}
	};
	window.Upload = upload;
})(window);
$(function(){
<#if resultCode?string != "-1">	
Upload.handleUpload("${resultCode!}", "${imgSrc!}");
</#if>	
	Upload.initUpload();
});
</script>
<form id="uploadForm" name="uploadForm" method="post" action="appAction.do?method=upload&type=2" enctype="multipart/form-data">
	<input type="hidden" id="imgSrc" name="imgSrc" value="${imgSrc!}"/>
	<input type="file" id="imgFile" name="imgFile"/>
</form>

<#include "../footer.html">